package wnhz.com.business.rebateshop.fragment;

import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import wnhz.com.business.BeginActivity;
import wnhz.com.business.R;
import wnhz.com.business.base.MyBaseActivity;
import wnhz.com.business.base.MyBaseFragment;
import wnhz.com.business.groupshop.ui.CreditNumActivity;
import wnhz.com.business.groupshop.ui.FundActivity;
import wnhz.com.business.groupshop.ui.HelpCenterActivity;
import wnhz.com.business.groupshop.ui.MeassageChangeActivity;
import wnhz.com.business.groupshop.ui.MessageActivity;
import wnhz.com.business.groupshop.ui.MyAttentionActivity;
import wnhz.com.business.groupshop.ui.MyCollectActivity;
import wnhz.com.business.rebateshop.activity.mine.AllOrderActivity;
import wnhz.com.business.rebateshop.activity.mine.MakeMerchatActivity;
import wnhz.com.business.rebateshop.activity.mine.SettingActivity;

/**
 * Created by Administrator on 2017-09-18 0018.
 * 我的
 */

public class MineFragment extends MyBaseFragment {


    @BindView(R.id.iv_r_head)
    ImageView ivRHead;
    @BindView(R.id.tv_r_userName)
    TextView tvRUserName;
    @BindView(R.id.tv_r_phone)
    TextView tvRPhone;
    @BindView(R.id.ll_r_xingyongnum)
    LinearLayout llRXingyongnum;
    @BindView(R.id.ll_r_message)
    LinearLayout llRMessage;
    @BindView(R.id.ll_r_allOrder)
    LinearLayout llRAllOrder;
    @BindView(R.id.ll_r_one)
    LinearLayout llROne;
    @BindView(R.id.ll_r_four)
    LinearLayout llRFour;
    @BindView(R.id.ll_r_two)
    LinearLayout llRTwo;
    @BindView(R.id.ll_r_three)
    LinearLayout llRThree;
    @BindView(R.id.ll_r_fifth)
    LinearLayout llRFifth;
    @BindView(R.id.ll_r_collect)
    LinearLayout llRCollect;
    @BindView(R.id.ll_r_attention)
    LinearLayout llRAttention;
    @BindView(R.id.ll_r_fund)
    LinearLayout llRFund;
    @BindView(R.id.ll_r_userFaith)
    LinearLayout llRUserFaith;
    @BindView(R.id.ll_r_shenqin)
    LinearLayout llRShenqin;
    @BindView(R.id.ll_r_refund)
    LinearLayout llRRefund;
    @BindView(R.id.ll_r_help)
    LinearLayout llRHelp;
    @BindView(R.id.tv_phone)
    TextView tvPhone;
    @BindView(R.id.ll_r_main)
    LinearLayout llRMain;
    @BindView(R.id.ll_r_setting)
    LinearLayout llRSetting;
    Unbinder unbinder;
    private MyBaseActivity activity;

    @Override
    protected void handleMsg(Message msg) {
        switch (msg.what) {
            case 5001:
                break;
        }
    }

    @Override
    protected View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_rebate_mine, container, false);
        activity = (MyBaseActivity) getActivity();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        return view;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        loadInfo();

        return rootView;
    }


    private void loadInfo() {
        handler.sendEmptyMessage(5001);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.iv_r_head, R.id.tv_r_userName, R.id.tv_r_phone, R.id.ll_r_xingyongnum, R.id.ll_r_message, R.id.ll_r_allOrder, R.id.ll_r_one, R.id.ll_r_four, R.id.ll_r_two, R.id.ll_r_three, R.id.ll_r_fifth, R.id.ll_r_collect, R.id.ll_r_attention, R.id.ll_r_fund, R.id.ll_r_userFaith, R.id.ll_r_shenqin, R.id.ll_r_refund, R.id.ll_r_help, R.id.ll_r_main, R.id.ll_r_setting})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_r_head://个人信息头像
                startActivity(MeassageChangeActivity.createIntent(activity));
                break;
            case R.id.tv_r_userName://个人信息名字
                startActivity(MeassageChangeActivity.createIntent(activity));
                break;
            case R.id.tv_r_phone://个人信息电话
                startActivity(MeassageChangeActivity.createIntent(activity));
                break;
            case R.id.ll_r_xingyongnum://信用值
                startActivity(CreditNumActivity.createIntent(activity));
                break;
            case R.id.ll_r_message://消息
                startActivity(MessageActivity.createIntent(activity));
                break;
            case R.id.ll_r_allOrder://所有订单
                startActivity(AllOrderActivity.createIntent(activity, "0"));
                break;
            case R.id.ll_r_one://待付款
                startActivity(AllOrderActivity.createIntent(activity, "1"));
                break;
            case R.id.ll_r_two://待发货
                startActivity(AllOrderActivity.createIntent(activity, "2"));
                break;
            case R.id.ll_r_three://待收货
                startActivity(AllOrderActivity.createIntent(activity, "3"));
                break;
            case R.id.ll_r_four://待评价
                startActivity(AllOrderActivity.createIntent(activity, "4"));
                break;
            case R.id.ll_r_fifth://退款、售后
                startActivity(AllOrderActivity.createIntent(activity, "5"));
                break;
            case R.id.ll_r_collect://我的收藏
                startActivity(MyCollectActivity.createIntent(activity));
                break;
            case R.id.ll_r_attention://我的关注
                startActivity(MyAttentionActivity.createIntent(activity));
                break;
            case R.id.ll_r_fund://我的钱包
                startActivity(FundActivity.createIntent(activity));
                break;
            case R.id.ll_r_userFaith://我的信用值
                startActivity(CreditNumActivity.createIntent(activity));
                break;
            case R.id.ll_r_shenqin://申请成为返利商家
                startActivity(MakeMerchatActivity.createIntent(activity));
                break;
            case R.id.ll_r_help://帮助中心
                startActivity(HelpCenterActivity.createIntent(activity, 2));//int   type   1-规则  2-帮助中心  3-信用秘籍
                break;
            case R.id.ll_r_refund://我的邀请

                break;
            case R.id.ll_r_main://返回主页
                startActivity(BeginActivity.createIntent(activity));
                activity.finish();
                break;
            case R.id.ll_r_setting://设置
                startActivity(SettingActivity.createIntent(activity));
                break;
        }
    }
}
